<#macro mapperEl value>${r"#{"}${value}}</#macro>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.fraudmetrix.forseti.dal.mysql.dao.${basePackage}.${className}Dao">

    <resultMap id="BaseResultMap" type="cn.fraudmetrix.forseti.dal.mysql.object.${basePackage}.${className}DO">
        <#list columnInfoList as columnInfo>
            <result column="${columnInfo.originName}" property="${columnInfo.lowerCamelName}" jdbcType="${columnInfo.jdbcType}"/>
        </#list>
    </resultMap>

    <sql id="Base_Column_List">
        <#list columnInfoList as columnInfo>
            <#if columnInfo_has_next>
        ${columnInfo.originName},
            <#else>
        ${columnInfo.originName}
            </#if>
        </#list>
    </sql>

    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
        select
        <include refid="Base_Column_List" />
        from ${tableName}
        where ${pkName} = ${r"#{"}${upperPkName},jdbcType=${pkType}}
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
        delete from ${tableName}
        where ${pkName} = ${r"#{"}${upperPkName},jdbcType=${pkType}}
    </delete>

    <insert id="insert" parameterType="cn.fraudmetrix.forseti.dal.mysql.object.${basePackage}.${className}DO" >
        insert into ${tableName} (<include refid="Base_Column_List" />)
        values (
    <#list columnInfoList as columnInfo>
        <#if columnInfo_has_next>
        ${r"#{"}${columnInfo.lowerCamelName},jdbcType="${columnInfo.jdbcType}},
        <#else>
        ${r"#{"}${columnInfo.lowerCamelName},jdbcType="${columnInfo.jdbcType}}
        </#if>
    </#list>
        )
    </insert>

    <insert id="insertSelective" parameterType="cn.fraudmetrix.forseti.dal.mysql.object.score.CommercialInfoDO" >
        insert into ${tableName}
        <trim prefix="(" suffix=")" suffixOverrides="," >
        <#list columnInfoList as columnInfo>
            <if test="${columnInfo.lowerCamelName} != null" >
                ${columnInfo.originName},
            </if>
        </#list>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides="," >
        <#list columnInfoList as columnInfo>
            <if test="${columnInfo.lowerCamelName} != null" >
            ${r"#{"}${columnInfo.lowerCamelName},jdbcType="${columnInfo.jdbcType}},
            </if>
        </#list>
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective" parameterType="cn.fraudmetrix.forseti.dal.mysql.object.score.CommercialInfoDO" >
        update ${tableName}
        <set >
        <#list columnInfoList as columnInfo>
            <#if columnInfo.lowerCamelName==pkName>
            <#else>
            <if test="${columnInfo.lowerCamelName} != null" >
              ${columnInfo.originName} = ${r"#{"}${columnInfo.lowerCamelName},jdbcType="${columnInfo.jdbcType}},
            </if>
            </#if>
        </#list>

        </set>
        where ${pkName} = ${r"#{"}${upperPkName},jdbcType=${pkType}}
    </update>

    <update id="updateByPrimaryKey" parameterType="cn.fraudmetrix.forseti.dal.mysql.object.score.CostItemDO" >
        update ${tableName}
    <#list columnInfoList as columnInfo>
        <#if columnInfo.lowerCamelName==pkName>
        <#elseif columnInfo_has_next>
          ${columnInfo.originName} = ${r"#{"}${columnInfo.lowerCamelName},jdbcType="${columnInfo.jdbcType}},
        <#else>
          ${columnInfo.originName} = ${r"#{"}${columnInfo.lowerCamelName},jdbcType="${columnInfo.jdbcType}}
        </#if>
    </#list>
        where ${pkName} = ${r"#{"}${upperPkName},jdbcType=${pkType}}
    </update>

    <update id="deleteByUpdate" parameterType="map">
        update ${tableName}
        set DELETE_FLAG = 1,
        GMT_MODIFIED = ${r"#{gmtModidied"}},
        UPDATE_BY = ${r"#{updateBy"}
        WHERE ${pkName} IN
        <foreach collection="ids" item="uuid" open="(" separator="," close=")">
        ${r"#{uuid"}}
        </foreach>
    </update>


    <select id="selectPage" resultType="cn.fraudmetrix.forseti.dal.mysql.dto.${basePackage}.${className}SearchDTO"
            resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM ${tableName}
        <where>
        <#list columnInfoList as columnInfo>
          <#if columnInfo.lowerCamelName==pkName>
          <#elseif columnInfo_has_next>
          <if test="${columnInfo.lowerCamelName} != null" >
            ${columnInfo.originName} = ${r"#{"}${columnInfo.lowerCamelName},jdbcType="${columnInfo.jdbcType}},
          </if>
          <#else>
          <if test="${columnInfo.lowerCamelName} != null" >
            ${columnInfo.originName} = ${r"#{"}${columnInfo.lowerCamelName},jdbcType="${columnInfo.jdbcType}}
          </if>
          </#if>
        </#list>
            and DELETE_FLAG = 0
        </where>
        ORDER BY GMT_CREATE DESC
    </select>


</mapper>
